package com.lagou.edu.message.mq.listener;

import com.lagou.edu.common.constant.MQConstant;
import com.lagou.edu.common.mq.dto.BaseMqDTO;
import com.lagou.edu.common.mq.listener.AbstractMqListener;
import com.lagou.edu.message.api.dto.Message;
import com.lagou.edu.message.service.IPushService;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;


@Slf4j
@Component
@RocketMQMessageListener(topic = MQConstant.Topic.COURSE_ON_SHELF, consumerGroup = "${rocketmq.producer.group}" + "_" + MQConstant.Topic.COURSE_ON_SHELF)
public class CourseOnShelfSendMessageListener extends AbstractMqListener<BaseMqDTO<String>> implements RocketMQListener<BaseMqDTO<String>>{
	
    @Autowired
    private IPushService pushService;

    @Override
    public void onMessage(BaseMqDTO<String> data) {
        log.info("收到消息：{}",data);
        Message message = new Message();
        message.setContent(data.getData());
        pushService.push(message);
    }
}